-- CALC_DORAEMON_BONUS

-- 未来猫道具奖励
-- @param user      玩家对象
-- @param bonusArg  奖励参数，即dungeon_element.csv表的args字段中配置的bonus_arg
return function(user, bonusArg)
    -- 获取随机种子
    local randSeed  = DungeonM.getRandSeed("CALC_DORAEMON_BONUS");

    -- 权重10：超级铜锣烧、妖怪定时器、泄愤计时沙漏
    -- 权重10：雷电云、放大灯、缩小灯
    -- 权重20：空气炮、空气手枪、铜锣烧
    -- 权重20：联想式推理放大镜、魔术师之手、龙卷风吸管
    local arr  = { {["classId"] = 7488, ["ratio"] = 10}, {["classId"] = 7491, ["ratio"] = 10}, {["classId"] = 7493, ["ratio"] = 10},
                   {["classId"] = 7494, ["ratio"] = 10}, {["classId"] = 7497, ["ratio"] = 10}, {["classId"] = 7498, ["ratio"] = 10},
                   {["classId"] = 7485, ["ratio"] = 20}, {["classId"] = 7486, ["ratio"] = 20}, {["classId"] = 7487, ["ratio"] = 20},
                   {["classId"] = 7489, ["ratio"] = 20}, {["classId"] = 7492, ["ratio"] = 20}, {["classId"] = 7495, ["ratio"] = 20}, };

    -- 权重20：任意门、外送电话、时光机(有次数限制)
    -- 权重30：竹蜻蜓、隐身外套、怪力手套(有次数限制)
    local arr2 = { {["classId"] = 7484, ["ratio"] = 20}, {["classId"] = 7490, ["ratio"] = 20}, {["classId"] = 7496, ["ratio"] = 20},
                   {["classId"] = 8221, ["ratio"] = 30}, {["classId"] = 8222, ["ratio"] = 30}, {["classId"] = 8223, ["ratio"] = 30}, };

    -- 是否配置了只给不限量物品
    bonusArg = bonusArg or {};
    local bonusType = bonusArg["bonus_type"];
    if bonusType ~= "normal" then
        -- 过滤掉有次数限制的物品
        for _, info in pairs(arr2) do
            if DungeonServiceM.isStatItemLimit(info["classId"]) then
                info["ratio"] = 0;
            end
        end

        -- 如果出战或链接了神灯冈布奥，则不出现时光机
        if ME.user.dbase:query("active_pet") == 54 then
            arr2[3]["ratio"] = 0;
        end

        local lictor = ME.user.dbase:query("lictor_pets") or {};
        if table.indexOf(lictor, 54) > 0 then
            arr2[3]["ratio"] = 0;
        end

        arr = table.append(arr, arr2);
    end

    local classId = fetchElemBySeed(arr, randSeed)["classId"];
    return {1, classId, 1};
end